package com.zian.controller.admin;

import com.zian.annotation.OperLog;
import com.zian.common.R;
import com.zian.domain.dto.PageDTO;
import com.zian.domain.po.SysOperLog;
import com.zian.domain.query.PageQuery;
import com.zian.service.ISysOperLogService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/admin/log")
@RequiredArgsConstructor
public class SysOperLogController {

    private final ISysOperLogService operLogService;


    @GetMapping("/page")
    @ApiOperation("查询日志列表")
    public R<PageDTO<SysOperLog>> queryPage(PageQuery query) {
        log.info("分页查询参数：{}", query);
        PageDTO<SysOperLog> pageDTO = operLogService.queryPage(query);
        return R.ok(pageDTO);
    }


    @GetMapping("/{id}")
    @ApiOperation("查询日志详情")
    public R<SysOperLog> getOperLogById(@PathVariable Long id) {
        log.info("查询日志详情参数：{}", id);
        SysOperLog operLog = operLogService.getById(id);
        return R.ok(operLog);
    }


}
